/*
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 */
package org.apache.qpid.server.security;

import org.apache.qpid.server.model.DerivedAttribute;
import org.apache.qpid.server.model.ManagedAttribute;
import org.apache.qpid.server.model.ManagedObject;
import org.apache.qpid.server.model.ManagedOperation;
import org.apache.qpid.server.model.TrustStore;

@ManagedObject(category = false, type = "SiteSpecificTrustStore",
        description = "Obtains a SSL/TLS certificate from a given URL which the Trust Store will trust for secure connections (e.g., HTTPS or AMQPS)")
public interface SiteSpecificTrustStore<X extends SiteSpecificTrustStore<X>> extends TrustStore<X>
{
    String CERTIFICATE = "certificate";

    @ManagedAttribute(immutable = true, description = "The URL from which to obtain the trusted certificate. This must include the protocol and port. Example: https://example.com:443")
    String getSiteUrl();

    @DerivedAttribute(persist = true, description = "The X.509 certificate obtained from the given URL as base64 encoded representation of the ASN.1 DER encoding")
    String getCertificate();

    @DerivedAttribute(description = "The distinguished name of the issuer of the certificate or null if no issuer information is present")
    String getCertificateIssuer();

    @DerivedAttribute(description = "The distinguished name of the subject of the certificate or null if no subject information is present")
    String getCertificateSubject();

    @DerivedAttribute(description = "The serial number of the certificate assigned by the CA or null if no serial number is present")
    String getCertificateSerialNumber();

    @DerivedAttribute(description = "A (possibly truncated) hex encoded representation of the signature. The bytes are separated by spaces. null if no signature information is present")
    String getCertificateSignature();

    @DerivedAttribute(description = "The start date of the validity of the certificate")
    String getCertificateValidFromDate();

    @DerivedAttribute(description = "The end date of the validity of the certificate")
    String getCertificateValidUntilDate();

    @ManagedOperation(description = "Re-download the certificate from the URL")
    void refreshCertificate();
}
